package com.kgcx.system.controller;

import com.kgcx.common.bean.ReturnData;
import com.kgcx.common.controller.BaseController;
import com.kgcx.system.domain.Suggestion;
import com.kgcx.system.service.SuggestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 吴刚林
 * @date 2017/11/29
 */
@Api(description = "意见接口", tags = "意见接口")
@RestController
@RequestMapping("suggestion")
public class SuggestionController extends BaseController {

    @Autowired
    private SuggestionService suggestionService;

    @ApiOperation(value = "新增意见", httpMethod = "POST", notes = "这是用来新增意见的接口")
    @PostMapping("addSuggestion")
    public ReturnData addSuggestion(@RequestBody Suggestion suggestion) {
        suggestionService.addSuggestion(suggestion);
        return new ReturnData<>();
    }

    @ApiOperation(value = "查询意见", httpMethod = "GET", notes = "这是用来查询意见的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "kid", value = "意见id", required = true, paramType = "query", dataType = "long", dataTypeClass = Long.class),
    })
    @GetMapping("getSuggestion")
    public ReturnData<Suggestion> getSuggestion(@RequestParam Long kid) {
        return new ReturnData<>(suggestionService.getSuggestion(kid));
    }

    @ApiOperation(value = "查询意见", httpMethod = "GET", notes = "这是用来查询意见的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "pageSize", value = "页容量", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "orderBy", value = "排序,sql格式", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class),
    })
    @GetMapping("getSuggestionList")
    public ReturnData<List<Suggestion>> getSuggestionList() {
        return new ReturnData<>(suggestionService.getSuggestionList(getRequestData()));
    }
}
